package com.sun.showcase.controller.mall;

import com.sun.showcase.biz.mall.service.SubjectClassifyService;
import com.sun.showcase.client.domain.mall.SubjectClassify;
import com.sun.showcase.client.query.mall.SubjectClassifyQuery;
import com.sun.showcase.pojo.DataGrid;
import com.sun.showcase.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping(value="/mall/subjectClassify")
public class SubjectClassifyController{
	
	@Autowired
	private SubjectClassifyService subjectClassifyService;
	
	private Result result = new Result();
	/**
	 * 跳转到SubjectClassify管理页面
	 * 
	 * @return
	 */
	@RequestMapping(value="goSubjectClassify")
	public String goSubjectClassify() {
		return "mall/subjectClassify";
	}
	/**
	 * 跳转到SubjectClassify新增页面
	 * 
	 * @return
	 */
	@RequestMapping(value="handleSubjectClassify")
	public String handleSubjectClassify(@RequestParam(value="id",required=false) Long id , ModelMap map) {
		return "mall/subjectClassify_rowEdit";
	}

	/**
	 * 跳转到查看desc页面
	 * 
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="showDesc")
	public SubjectClassify showDesc(SubjectClassifyQuery subjectClassifyQuery) {
		return subjectClassifyService.get(subjectClassifyQuery);
	}

	/**
	 * 获得分页数据表格
	 */
	@ResponseBody
	@RequestMapping(value = "/datagrid")
	public DataGrid datagrid(SubjectClassifyQuery subjectClassifyQuery) {
		return subjectClassifyService.datagrid(subjectClassifyQuery);
	}
	

	/**
	 * 添加一个SubjectClassify
	 */
	@ResponseBody
	@RequestMapping(value="add")
	public Result add(SubjectClassifyQuery subjectClassifyQuery) {
		subjectClassifyService.add(subjectClassifyQuery);
		result.setSuccess(true);
		result.setMsg("添加成功！");
		return result;
	}

	/**
	 * 编辑SubjectClassify
	 */
	@ResponseBody
	@RequestMapping(value="edit")
	public Result edit(SubjectClassifyQuery subjectClassifyQuery) {
		subjectClassifyService.update(subjectClassifyQuery);
		result.setSuccess(true);
		result.setMsg("编辑成功！");
		return result;
	}

	/**
	 * 物理删除SubjectClassify
	 */
	@ResponseBody
	@RequestMapping(value="delete")
	public Result delete(SubjectClassifyQuery subjectClassifyQuery) {
		subjectClassifyService.delete(subjectClassifyQuery.getIds());
		result.setSuccess(true);
		result.setMsg("删除成功！");
		return result;
	}
	
	/**
	 * 逻辑删除SubjectClassify
	 */
	@ResponseBody
	@RequestMapping(value="deletePt")
	public Result deletePt(SubjectClassifyQuery subjectClassifyQuery) {
		subjectClassifyService.deletePt(subjectClassifyQuery.getIds());
		result.setSuccess(true);
		result.setMsg("删除成功！");
		return result;
	}
	/**
	 * 全部数据SubjectClassify
	 */
	@ResponseBody
	@RequestMapping(value="listAll")
	public Result listAll(SubjectClassifyQuery subjectClassifyQuery) {
		List<SubjectClassifyQuery> list = subjectClassifyService.listAll(subjectClassifyQuery);
		result.setSuccess(true);
		result.setMsg("成功！");
		result.setData(list);
		return result;
	}
}
